<?php
@session_start();

require_once("../includes/public.inc.php");
$act = isset($_GET['act'])?$_GET['act']:'';
$type = isset($_GET['type'])?$_GET['type']:'';
$s = isset($_POST['s'])?$_POST['s']:'';
$user =  isset($_POST['phone'])?trim($_POST['phone']):'';
$openid = isset($_POST['openid'])?trim($_POST['openid']):'';
if ($act=='login'&& $user)
{
	if ($type == 'user')
	{
		$exsit_user = mysql_fetch_array(mysql_query("select * from ".DBQIAN."users where username='".$user."' order by id desc limit 1"));
		//print_r($exsit_user);exit;
		if ($exsit_user)
		{
			if ($s)
			{
				$fwm = mysql_fetch_array(mysql_query("select id,fwm,time from ".DBQIAN."fwm where fwm='".trim($s)."' and userstatus=0 order by id desc limit 1"));//未使用,未领取奖品的
				if ($fwm['id'])
				{	//如果没有领过
					$_SESSION['username'] = $exsit_user['username'];
					header("Location: zhengpu.php?s=".trim($s)."&openid=".$openid);exit;
				}
				else 
				{
					//领过
					header("Location: mom_tip.php?status=1&s=".$s);exit;
				}
			}
			else 
			{
				//echo 456;exit;
				echo "<script>alert('非法防伪码');history.go(-1);</script>";exit;
			}
		}
		else 
		{
			echo "<script>alert('登录失败!');history.go(-1);</script>";exit;
		}
	}
	else 
	{
		echo "<script>alert('非法登录');history.go(-1);</script>";exit;
	}
}
else 
{
	echo "<script>alert('请别乱穿越好吧！你的操作已经被记录！后果自负！');history.go(-1);</script>";exit;	
}

//function user_logincheck()
//{
//	if (!isset($_SESSION['username']) ||$_SESSION['username'] == '')
//	{
//		echo "<script>window.parent.location.href='login.php';</script>";
//		exit;
//	}
//}
?>
